package com.gzmu.storage.mapper;

import com.gzmu.storage.entity.Station;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xiaobo Yan
 * @since 2020-04-16
 */
@Mapper
public interface StationMapper extends BaseMapper<Station> {

    @Insert("INSERT INTO t_station(name,serial,status,address,principal,telnum,createtime,updatetime,remark) VALUES(#{name}," +
            "#{serial},#{status},#{address},#{principal},#{telnum},now(),now(),#{remark}) ON DUPLICATE KEY UPDATE name=#{name}," +
            "serial=#{serial},status=#{status},address=#{address},principal=#{principal},telnum=#{telnum},updatetime=now(),remark=#{remark}")
    @Options(useGeneratedKeys = true)
    boolean insertAndUpdate(Station station);

    @Update( "UPDATE t_station SET status=#{status} WHERE id=#{id}" )
    boolean updateStationStatus(@Param( "id" ) Integer id, @Param( "status" ) Integer status);
}
